package com.prueba.client.interfaz.antigua;



import com.prueba.client.datos.AccionesData;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;

public class PlanDeAcciones extends ListGrid {
	private static PlanDeAcciones INSTANCE = null;
	
	protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {  

	    String fieldName = this.getFieldName(colNum);  
	    if (fieldName.equals("dirweb")) {  
	        IButton button = new IButton();  
	        button.setHeight(18);  
	        button.setWidth(150);                      
	        //button.setIcon("ponerImagenDespues.png");  
	        button.setTitle("Acceder");  
	        
	        button.addClickHandler(new ClickHandler() {  
	            public void onClick(ClickEvent event) {  
	                //SC.say(record.getAttribute("seccion") + " pagina.");  
	            }  
	        }); 
	        return button;  
	    } else {  
	        return null;  
	    }  };
	
	private PlanDeAcciones(){
		super();
		this.setShowAllRecords(true);  
        ListGridField accion = new ListGridField("accion", "Accion");  
        ListGridField estado = new ListGridField("estado", "Estado");
        ListGridField dirweb = new ListGridField("dirweb","Direccion Seccion");
        this.setShowRecordComponents(true);
        this.setShowRecordComponentsByCell(true);
        this.setFields(accion, estado,dirweb);
        this.setDataSource(AccionesData.getInstance());
        
      //  this.setAutoFetchData(true);
        
	}
	
	 private static void createInstance() {
	        if (INSTANCE == null) { 
	            INSTANCE = new PlanDeAcciones();}
	        }
	
	 public static PlanDeAcciones getInstance() {
	    if (INSTANCE == null) createInstance();
	    return INSTANCE;
	        }	   
}
